package com.ruoyi.project.wx.service.impl;

import cc.openkit.common.KitUtil;
import com.github.pagehelper.PageInfo;
import com.google.gson.Gson;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bootdo.*;
import com.ruoyi.common.utils.http.HttpUtils;
import com.ruoyi.project.mall.dao.MallCompanyUserDao;
import com.ruoyi.project.mall.dao.MallShopUserDao;
import com.ruoyi.project.mall.domain.MallCompanyUserDO;
import com.ruoyi.project.mall.domain.MallShopUserDO;
import com.ruoyi.project.wx.dao.*;
import com.ruoyi.project.wx.domain.CmsSlideDO;
import com.ruoyi.project.wx.domain.MemberCodeDO;
import com.ruoyi.project.wx.domain.MemberUserDO;
import com.ruoyi.project.wx.service.MemberTokenService;
import com.ruoyi.project.wx.service.MemberUserService;
import com.ruoyi.project.wx.service.OrderComService;
import com.ruoyi.project.wx.service.SetImageUploadService;
import org.apache.commons.beanutils.BeanUtils;
import org.jsoup.Connection.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import java.awt.image.BufferedImage;
import java.io.InputStream;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;


@Service
public class MemberUserServiceImpl implements MemberUserService {
	@Autowired
	private MemberUserDao memberUserDao;
	@Autowired
	private OrderComService orderComService;
	@Autowired
	private MemberCouponDao memberCouponDao;
	@Autowired
	private OrderOrderDao orderOrderDao;
	@Autowired
	public CmsSlideDao cmsSlideDao;
	@Autowired
	public MemberTokenService memberTokenService;
	@Autowired
	public SetImageUploadService setImageUploadService;
	@Autowired
	private MemberCodeDao memberCodeDao;
	@Autowired
	private MallCompanyUserDao mallCompanyUserDao;
	@Autowired
	private MallShopUserDao mallShopUserDao;
	
	@Override
	public MemberUserDO get(String id){
		return memberUserDao.get(id);
	}
	
	@Override
	public List<MemberUserDO> list(Map<String, Object> map){
		return memberUserDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return memberUserDao.count(map);
	}
	
	@Override
	public int save(MemberUserDO memberUser){
		return memberUserDao.save(memberUser);
	}
	
	@Override
	public int update(MemberUserDO memberUser){
		return memberUserDao.update(memberUser);
	}
	
	@Override
	public int remove(String id){
		return memberUserDao.remove(id);
	}
	
	@Override
	public int batchRemove(String[] ids){
		return memberUserDao.batchRemove(ids);
	}

	/*个人详细信息*/
	@Override
	public Map<String,Object> getMemberCenter(Map<String, Object> params) {
		String userId = params.get("userId").toString();
		MemberUserDO memberUserDO = memberUserDao.get(userId);
		Map<String,Object> map = new HashMap<String,Object>();
		//用信息
		map.put("phone",memberUserDO.getPhone());
		map.put("wechat",memberUserDO.getPassword());
		map.put("name",memberUserDO.getName());
		map.put("avator",memberUserDO.getAvator());
		map.put("InvitationCode",memberUserDO.getCode());
		//所有上级
		map.put("level", memberUserDO.getLevel());
		List<Map<String, Object>> upList = memberUserDao.findUpUser();
		map.put("upList", upList);
		
		String introUser = memberUserDO.getIntroUser();
		MemberUserDO introUserDO = memberUserDao.get(introUser);
		if (introUserDO == null) {
			map.put("fatherAvator","");
			map.put("fatherName","");
		} else {
			map.put("fatherAvator",introUserDO.getAvator());
			map.put("fatherName",introUserDO.getName());
		}

		//余额
		Map<String,Object> moneyMap = orderComService.getMemberCom(params);
		map.put("kPrice", moneyMap.get("kPrice"));   //可用余额
		map.put("allPrice", moneyMap.get("allPrice"));   //总余额
		params.remove("type");
		//优惠券数量
		List<String> types = new ArrayList<String>();
		types.add("0");
		params.put("types", types);
		int couponNum = memberCouponDao.getMyCouponList(params).size();
		map.put("couponNum", couponNum);   //优惠券总数
		//订单个数
		params.remove("types");
		String [] status = new String[10];
		status[0] = "1";
		params.put("status", status);
		int payNum = orderOrderDao.getOrderListByStatus(params).size();
		status[0] = "3";
		int faNum = orderOrderDao.getOrderListByStatus(params).size();
		status[0] = "4";
		int shouNum = orderOrderDao.getOrderListByStatus(params).size();
		params.put("type","4");
		status[0] = "7";
		int pingNum = orderOrderDao.getOrderListByStatus(params).size();
		params.remove("type");
		status[0] = "5";
		status[1] = "6";
		status[2] = "8";
		int errorNum = orderOrderDao.getOrderListByStatus(params).size();
		map.put("payNum", payNum);   //待支付
		map.put("faNum", faNum);   //待发货
		map.put("shouNum", shouNum);   //待收货
		map.put("pingNum", pingNum);   //待评价
		map.put("errorNum", errorNum);   //错误订单
		//我的粉丝
		params.remove("status");
		SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		int allNum = memberUserDao.getFansNum(params);   //总共粉丝数
		params.put("staTime", format.format(DateUtils.getDayBegin()));
		int todayNum = memberUserDao.getFansNum(params);   //今天粉丝数
		params.put("endTime", format.format(DateUtils.getDayBegin()));
		params.put("staTime", format.format(DateUtils.getBeginDayOfYesterday()));
		int yesterdayNum = memberUserDao.getFansNum(params);   //昨天粉丝数
		map.put("allNum",allNum);
		map.put("todayNum",todayNum);
		map.put("yesterdayNum",yesterdayNum);
		return map;
	}

	@Override
	public PageInfo<Map<String,Object>> getMyFans(Map<String, Object> paramMap) {
		PageHelperUtils.page(paramMap);
		List<Map<String,Object>> list =memberUserDao.getMyFans(paramMap);
		PageInfo<Map<String,Object>> pageInfo = new PageInfo<>(list);
		return pageInfo;
	}

	@Override
	public MemberUserDO queryByOpenid(String openId) {
		return memberUserDao.queryByOpenid(openId);
	}

	@Override
	public List<Map<String,Object>> getOrderEcharts(Map<String,Object> map) {
		return memberUserDao.getOrderEcharts(map);
	}

	@Override
	public List<Map<String,Object>> allMoneyEcharts(Map<String,Object> map) {
		return memberUserDao.allMoneyEcharts(map);
	}

	@Override
	public List<Map<String,Object>> allUserEcharts(Map<String,Object> map) {
		return memberUserDao.allUserEcharts(map);
	}

	@Override
	public MemberUserDO getByCode(String code) {
		return memberUserDao.getByCode(code);
	}

	@Override
	public R getExtension(Map<String, Object> params) {
		String userId = params.get("userId").toString();
		Map<String,Object> map = new HashMap<String,Object>();
		MemberUserDO userDO = memberUserDao.get(userId);
		map.put("avator",userDO.getAvator());
		map.put("name", userDO.getName());
		map.put("InvitationCode",userDO.getCode());
		String code = userDO.getCode();
		params.clear();
		params.put("type", "6");
		List<CmsSlideDO> imgList = cmsSlideDao.queryAll(params);
		if (imgList.size() == 0) {
			map.put("imgurl","");
		} else {
			map.put("imgurl",imgList.get(0).getImgUrl());
		}
		if (userDO.getQrcode() != null && !"".equals(userDO.getQrcode())) {
			map.put("qrCode",userDO.getQrcode());
		} else {   //如果库里面没有生成二维码，就生成
			String token = memberTokenService.getToken();
			String url="https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token="+token;
			Map<String,String> urlMap = new HashMap<String,String>();
			//urlMap.put("access_token",token); 不能传，会报错，微信文档错了
			urlMap.put("scene",code);
			try {
				Gson gson = new Gson();
				Response response = HttpUtils.post(url, gson.toJson(urlMap));
				String contentType = response.contentType();
				if (!"image/jpeg".equals(contentType)) {   //没返回图片
					String body = response.body();
					Map<String, Object> resultMap = new HashMap<String, Object>();
					resultMap = gson.fromJson(body, resultMap.getClass());
					System.out.print("获取二维码结果：：" + resultMap.toString());
					return R.error("获取二维码code值："+resultMap.get("errcode").toString());
				}
				//图片上传
				InputStream is = response.bodyStream();
				byte [] imgByte = StringUtils.readInputStream(is);
				BufferedImage image = ImageIO.read(is);
				String fileName = null;
				if (image != null) {//如果image=null 表示上传的不是图片格式
					fileName = "IMG_" + image.getWidth() + "_" + image.getHeight() + "@"+ UUID.randomUUID().toString();;
				}else {
					fileName = UUID.randomUUID().toString();
				}
				String imagePath = new ImgUpload(setImageUploadService).upload(imgByte,
						fileName);
				System.out.println("生成二维码地址地址：："+imagePath);
				MemberUserDO memberUserDO = new MemberUserDO();
				memberUserDO.setId(userId);
				memberUserDO.setQrcode(imagePath);
				memberUserDao.update(memberUserDO);
				map.put("qrCode",imagePath);
			} catch (Exception e) {
				e.printStackTrace();
				return R.error("生成二维码失败");
			}
		}
		return R.ok().put("data",map);
	}

	@Override
	public List<Map<String,Object>> getMoneyListByUser(Map<String,Object> map) {
		return memberUserDao.getMoneyListByUser(map);
	}

	@Override
	public int getMoneyListByUserCount(Map<String, Object> map) {
		return memberUserDao.getMoneyListByUserCount(map);
	}

	//导出excel。改变订单导出状态
	@Override
	@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED) // 有事务则加入,没有则建立
	public void exportExcel(Map<String,Object> map,List<Map<String,Object>> userList,
							ServletOutputStream out,HttpServletRequest request) {
		//导出excel
		//MemberMoneyExcelUtils.exportUserExcel(userList, out);

	}

	@Override
	public List<Map<String,Object>> getMyFansH(Map<String,Object> map) {
		return memberUserDao.getMyFansH(map);
	}

	@Override
	public int getMyFansHCount(Map<String, Object> map) {
		return memberUserDao.getMyFansHCount(map);
	}

	@Override
	public BigDecimal getShoppingNum(Map<String,Object> map) {
		return memberUserDao.getShoppingNum(map);
	}

	@Override
	public List<Map<String,Object>> getShoppingList(Map<String,Object> map) {
		return memberUserDao.getShoppingList(map);
	}

	@Override
	public int getShoppingListCount(Map<String, Object> map) {
		return memberUserDao.getShoppingListCount(map);
	}

	@Override
	@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED) // 有事务则加入,没有则建立
	public void shoppingExportExcel(Map<String,Object> map,List<Map<String,Object>> shoppingList,
							ServletOutputStream out,HttpServletRequest request) {
		//导出excel
		//MemberMoneyExcelUtils.exportPTShoppingExcel(shoppingList, out);
	}

	@Override
	public Tree<MemberUserDO> getTree() {
		List<Tree<MemberUserDO>> trees = new ArrayList<Tree<MemberUserDO>>();
		List<MemberUserDO> members = memberUserDao.findByLevelNotD(new HashMap<>(16));
		for (MemberUserDO memberUserDO : members) {
			Tree<MemberUserDO> tree = new Tree<MemberUserDO>();
			tree.setId(memberUserDO.getId());
			tree.setParentId(memberUserDO.getIntroUser());
			tree.setText(memberUserDO.getName());
			Map<String, Object> state = new HashMap<>(16);
            state.put("opened", true);
            state.put("mType", "user");
            tree.setState(state);
			trees.add(tree);
		}
		// 默认顶级大类为０，根据数据库实际情况调整
		Tree<MemberUserDO> t = BuildTree.build(trees);
		return t;
	}

	@Override
	public R login(Map<String, Object> map) {
		List<MemberCodeDO> list = memberCodeDao.list(map);
		if(list.size()<=0){
			return R.error("验证码错误");
		}
		MemberUserDO findByPhone = memberUserDao.findByPhone(map.get("phone").toString());
		MemberUserDO memberUserDO = memberUserDao.get(map.get("userId").toString());
		if(findByPhone==null){
			memberUserDO.setPhone(map.get("phone").toString());
			if(memberUserDao.update(memberUserDO)>0){
				return R.ok().put("data", memberUserDO);
			}
		}else{
			memberUserDO.setCreateAt(new Date());
			memberUserDO.setLevel(findByPhone.getLevel());
			memberUserDO.setPhone(findByPhone.getPhone());
			memberUserDO.setIntroUser(findByPhone.getIntroUser());
			memberUserDO.setName(findByPhone.getName());
			memberUserDao.remove(findByPhone.getId());
			if(memberUserDao.update(memberUserDO)>0){
				
				return R.ok().put("data", memberUserDO);
			}
		}
		
		return R.error("操作失败,请重试");
	}

	@Override
	public Tree<MemberUserDO> getTree(String userId) {
		List<Tree<MemberUserDO>> trees = new ArrayList<Tree<MemberUserDO>>();
		int level = 0;
		if(!("0").equals(userId)){
			MemberUserDO memberUserDO2 = memberUserDao.get(userId);
			level=memberUserDO2.getLevel();
		}
		
		List<MemberUserDO> members = memberUserDao.findByLevel(level);
		for (MemberUserDO memberUserDO : members) {
			Tree<MemberUserDO> tree = new Tree<MemberUserDO>();
			tree.setId(memberUserDO.getId());
			tree.setParentId(memberUserDO.getIntroUser());
			tree.setText(memberUserDO.getName());
			Map<String, Object> state = new HashMap<>(16);
            state.put("opened", true);
            state.put("mType", "user");
            tree.setState(state);
			trees.add(tree);
		}
		// 默认顶级大类为０，根据数据库实际情况调整
		Tree<MemberUserDO> t = BuildTree.build(trees);
		return t;
	}

	@Override
	public R saveMemberUserRegister(Map<String, Object> params) {
		//查看验证码
		params.put("delFlag",0);
		List<MemberCodeDO> list = memberCodeDao.list(params);
		if(list.size()<=0){
			return R.error("验证码有误");
		}
		//查看手机号
		MemberUserDO memberUserDO = memberUserDao.findByPhone(params.get("phone").toString());
		if(memberUserDO!=null){
			return R.error("手机号已注册");
		}else{
			memberUserDO = new MemberUserDO();
			memberUserDO.setMoney(new BigDecimal("0.00"));
			memberUserDO.setId(UuidUtil.get32UUID());
			memberUserDO.setFreeze(new BigDecimal("0.00"));
			memberUserDO.setDisabled(0);
			memberUserDO.setDelFlag(0);
			memberUserDO.setCreateAt(new Date());
			memberUserDO.setSex(0);
			memberUserDO.setName("昵称"+ KitUtil.getStringRandom(8));
			memberUserDO.setAvator("https://tse2-mm.cn.bing.net/th/id/OIP.IykEwu6UUNOvq9LFU0d3kwAAAA?w=164&h=180&c=7&o=5&dpr=1.25&pid=1.7");
			memberUserDO.setLevel(0);
			String encrypt = MD5Utils.encrypt(params.get("phone").toString(), params.get("password").toString());
			memberUserDO.setPassword(encrypt);
			memberUserDO.setPhone(params.get("phone").toString());
			memberUserDO.setUpdateAt(new Date());
			memberUserDao.save(memberUserDO);
			return R.ok();
		}




	}

	@Override
	public R memberUserLogin(Map<String, Object> params) {

			//用户
			MemberUserDO phone = memberUserDao.findByPhone(params.get("phone").toString());
			if(phone==null){
				return R.error("手机号有误");
			}else{
				if(phone.getLevel()==1){
					MallShopUserDO mallShopUserDO = mallShopUserDao.findByUserId(phone.getId());
					if(mallShopUserDO==null){
						return R.error("用户信息有误");
					}
					if(mallShopUserDO.getStatus()==0){
						return R.error("正在审核中");
					}else if(mallShopUserDO.getStatus()==2){
						return R.error("审核被拒绝,请联系平台");
					}

				}
				String encrypt = MD5Utils.encrypt(params.get("phone").toString(), params.get("password").toString());
				Map<String,Object> map = new HashMap<>();
				map.put("delFlag","0");
				map.put("phone",params.get("phone").toString());
				map.put("password",encrypt);
				List<MemberUserDO> list = memberUserDao.list(map);
				if(list.size()<=0){
					return R.error("密码有误");
				}else{
					return R.ok().put("data",list.get(0));
				}

			}



	}

    @Override
    public R getUserInfo(Map<String, Object> params) {
		Map<String,Object> map = memberUserDao.getUserInfo(params.get("userId").toString());
		if(map.get("level").toString().equals("2")){
			MallCompanyUserDO mallCompanyUserDO = mallCompanyUserDao.getByUserId(params.get("userId").toString());
			map.put("mallCompanyUserDO" ,mallCompanyUserDO);
		}
		return R.ok().put("data",map);


	}

    @Override
    public R updateUser(Map<String, Object> params) {
		try {
			params.put("id",params.get("userId").toString());
			params.remove("userId");
			MemberUserDO memberUserDO =new MemberUserDO();
			BeanUtils.populate(memberUserDO,params);
			memberUserDao.update(memberUserDO);
			return R.ok(0,"修改成功");
		} catch (Exception e) {
			e.printStackTrace();
			return R.error("修改失败");
		}


	}

	@Override
	public R updateUserPassword(Map<String, Object> params) {
		MemberUserDO phone = memberUserDao.findByPhone(params.get("phone").toString());
		if(phone==null){
			return R.error("手机号有误");
		}

		String encrypt = MD5Utils.encrypt(params.get("phone").toString(), params.get("oldPassword").toString());
		params.put("password",encrypt);
		List<MemberUserDO> list = memberUserDao.list(params);
		if(list.size()<=0){
			return R.error("旧密码有误,请重新输入");
		}else{
			String newEncrypt = MD5Utils.encrypt(params.get("phone").toString(), params.get("newPassword").toString());
			phone.setPassword(newEncrypt);
			phone.setUpdateAt(new Date());
			memberUserDao.update(phone);
			return R.ok();
		}


	}

	@Override
	public R forgetPassword(Map<String, Object> params) {
		MemberUserDO phone = memberUserDao.findByPhone(params.get("phone").toString());
		if(phone==null){
			return R.error("手机号有误");
		}

		List<MemberCodeDO> list1 = memberCodeDao.list(params);
		if(list1.size()<=0){
			return R.error("验证码有误");
		}
			String newEncrypt = MD5Utils.encrypt(params.get("phone").toString(), params.get("newPassword").toString());
			phone.setPassword(newEncrypt);
			phone.setUpdateAt(new Date());
			memberUserDao.update(phone);
			return R.ok();
		}

    @Override
    public R addCompanyUser(Map<String, Object> params) {
		MemberUserDO memberUserDO = memberUserDao.findByPhone(params.get("phone").toString());
		if(memberUserDO!=null){
			return R.error("手机号已注册");
		}else{
			//添加用户表
			memberUserDO = new MemberUserDO();
			memberUserDO.setIntroUser("0");
			memberUserDO.setName(params.get("name").toString());
			memberUserDO.setAvator("https://tse2-mm.cn.bing.net/th/id/OIP.IykEwu6UUNOvq9LFU0d3kwAAAA?w=164&h=180&c=7&o=5&dpr=1.25&pid=1.7");
			memberUserDO.setSex(0);
			memberUserDO.setDisabled(0);
			memberUserDO.setCreateAt(new Date());
			memberUserDO.setDelFlag(0);
			memberUserDO.setId(UuidUtil.get32UUID());
			memberUserDO.setLevel(2);
			memberUserDO.setPhone(params.get("phone").toString());
			String encrypt = MD5Utils.encrypt(params.get("phone").toString(), params.get("password").toString());
			memberUserDO.setPassword(encrypt);
			memberUserDO.setUpdateAt(new Date());
			//添加企业表
			MallCompanyUserDO mallCompanyUserDO =new MallCompanyUserDO();
			mallCompanyUserDO.setId(UuidUtil.get32UUID());
			mallCompanyUserDO.setLevel(Integer.parseInt(params.get("level").toString()));
			mallCompanyUserDO.setUserId(memberUserDO.getId());
			mallCompanyUserDO.setPhone(params.get("phone").toString());
			mallCompanyUserDO.setParentId(params.get("parentId").toString());
			mallCompanyUserDO.setCaAt(new Date());
			mallCompanyUserDO.setDelFlag(0);
			mallCompanyUserDO.setPassword(encrypt);
			mallCompanyUserDO.setCreateId(params.get("userId").toString());
			memberUserDao.save(memberUserDO);
			mallCompanyUserDao.save(mallCompanyUserDO);
			return R.ok(0,"添加成功");
		}

	}

	@Override
	public R getUpUser(Map<String, Object> params) {
		List<Map<String,Object>> mapList =  mallCompanyUserDao.getUpUser(params);
		return R.ok().put("data",mapList);
	}

	@Override
	public R getCompanyUserList(Map<String, Object> params) {
		PageHelperUtils.page(params);
		List<Map<String,Object>> mapList = mallCompanyUserDao.getCompanyUserList(params);
		PageInfo<Map<String,Object>> pageInfo = new PageInfo<>(mapList);
		return R.ok().put("data",pageInfo);
	}

	@Override
	public R updateCompanyUserPassword(Map<String, Object> params) {
		MallCompanyUserDO mallCompanyUserDO = mallCompanyUserDao.get(params.get("companyUserId").toString());
		if(mallCompanyUserDO==null){
			return R.error("采购员信息有误");
		}else{
			MemberUserDO memberUserDO = memberUserDao.get(mallCompanyUserDO.getUserId());
			if(memberUserDO==null){
				return R.error("用户信息有误");
			}else{
				String password = MD5Utils.encrypt(memberUserDO.getPhone(), params.get("password").toString());
				memberUserDO.setPassword(password);
				memberUserDO.setUpdateAt(new Date());
				mallCompanyUserDO.setPassword(password);
				mallCompanyUserDO.setUpAt(new Date());
				mallCompanyUserDao.update(mallCompanyUserDO);
				memberUserDao.update(memberUserDO);
				return R.ok(0,"修改成功");
			}
		}
	}

	@Override
	public R updateCompanyUserInfo(Map<String, Object> params) {
		try {
			MallCompanyUserDO mallCompanyUserDO = mallCompanyUserDao.get(params.get("companyUserId").toString());
			mallCompanyUserDO.setParentId(params.get("parentId").toString());
			mallCompanyUserDO.setLevel(Integer.parseInt(params.get("level").toString()));
			mallCompanyUserDO.setUpAt(new Date());
			mallCompanyUserDao.update(mallCompanyUserDO);
			MemberUserDO memberUserDO = memberUserDao.get(mallCompanyUserDO.getUserId());
			if(memberUserDO==null){
				return R.error("用户信息有误");
			}else{
				memberUserDO.setName(params.get("name").toString());
				memberUserDO.setUpdateAt(new Date());
				memberUserDao.update(memberUserDO);
				return R.ok();
			}

		} catch (Exception e) {
			e.printStackTrace();
			return R.error();
		}
	}

	@Override
	public R deleteCompanyUser(Map<String, Object> params) {
		MallCompanyUserDO mallCompanyUserDO = mallCompanyUserDao.get(params.get("companyUserId").toString());
		MemberUserDO memberUserDO = memberUserDao.get(mallCompanyUserDO.getUserId());
		memberUserDO.setUpdateAt(new Date());
		memberUserDO.setDelFlag(1);
		memberUserDao.update(memberUserDO);
		mallCompanyUserDO.setDelFlag(1);
		mallCompanyUserDO.setUpAt(new Date());
		mallCompanyUserDao.update(mallCompanyUserDO);
		return R.ok(0,"删除成功");
	}

	@Override
	public R getCompanyUserInfo(Map<String, Object> params) {
		MallCompanyUserDO mallCompanyUserDO = mallCompanyUserDao.get(params.get("companyUserId").toString());
		MemberUserDO memberUserDO = memberUserDao.get(mallCompanyUserDO.getUserId());
		Map<String,Object> map = new HashMap<>();
		map.put("companyUserId",mallCompanyUserDO.getId());
		map.put("name",memberUserDO.getName());
		map.put("phone",memberUserDO.getPhone());
		map.put("parentId",mallCompanyUserDO.getParentId());
		map.put("level",mallCompanyUserDO.getLevel());
		return R.ok().put("data",map);

	}

    @Override
    public List<MemberUserDO> likeList(Map<String, Object> stringObjectMap) {
		List<MemberUserDO> list= memberUserDao.likeList(stringObjectMap);
		return list;

    }

}
